
import JSEncrypt from "jsencrypt"

const setPublicCode = (val: string) => {
  if (!val) return
  const publicKey = import.meta.env.VITE_PUBLIC_KEY
  const encrypt = new JSEncrypt();
  // 设置公钥
  encrypt.setPublicKey(publicKey);
  // 加密消息
  const encrypted = encrypt.encrypt(val);
  return encrypted
}

export default setPublicCode
